<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/WdatePicker.css" rel="stylesheet" type="text/css" />
<link href="css/select.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
<script type="text/javascript" src="js/select-ui.min.js"></script>
<script type="text/javascript" src="js/WdatePicker.js"></script>

    <script type="text/javascript">
        $(document).ready(function(e) {
            $(".select1").uedSelect({
                width : 345
            });
            $(".select2").uedSelect({
                width : 167
            });
            $(".select3").uedSelect({
                width : 100
            });
        });
    </script>

</head>

<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">表单</a></li>
    </ul>
    </div>

    <div class="formbody">

    <div class="formtitle"><span>客户信息</span></div>

    <ul class="forminfo">
<form id="form1" name="form1">
    <li><label style="width:18px;"><b>*</b></label><label>客户全称</label><input name="cus_fname" id="cus_fname" type="text" class="dfinput" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户简称</label><input name="cus_aname" id="cus_aname" type="text" class="dfinput" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户分类</label><cite><input name="cus_cate"  type="radio" value="品牌" checked="checked" />品牌&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_cate" type="radio" value="SCP" />SCP</cite></li>
    <li><label style="width:18px;"><b>*</b></label><label>所属区域</label>
    <div class="vocation">
        <select class="select2" name='cus_area' id="cus_area">
            <option value='华中地区'>华中地区</option>
            <option value='华南地区'>华南地区</option>
            <option value='华北地区'>华北地区</option>
        </select>
    </div>
    </li>
    <li></li>
    <li><label style="width:18px;"><b>*</b></label><label>省市</label>
           <div class="vocation"> <select class="select3" id="s_province" name="s_province"></select> </div> 
            <div class="vocation"><select class="select3" id="s_city" name="s_city" ></select> </div> 
            <div class="vocation"><select class="select3" id="s_county" name="s_county"></select></div>
            <script class="resources library" src="js/area.js" type="text/javascript"></script>

            <script type="text/javascript">_init_area();</script>

        <div id="show"></div>
    </li>
    <li><label style="width:18px;"><b>*</b></label><label>地址</label><input name="cus_address" id="cus_address" type="text" class="dfinput" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>负责人</label><input name="cus_linkman" id="cus_linkman" type="text" class="dfinput" placeholder="只能填写一个" /><i></i></li>
    <li><label style="width:18px;"><b>*</b></label><label>手机</label><input name="cus_phone" id="cus_phone" type="text" class="dfinput" placeholder="只能填写一个，用于短信提醒功能" /></li>
    <li><label style="width:18px;"><b></b></label><label>身份证号</label><input name="cus_identity_num" id="cus_identity_num" type="text" class="dfinput" placeholder="负责人身份证号" /></li>
    <!--通过身份证号码获取生日，性别-->
    <script>
        $('#cus_identity_num').blur(function(){
            //获取输入身份证号码
            var UUserCard = $(this).val();
            //获取出生日期
            var birthday = UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
            $('#cus_birthday').val(birthday);
            //获取性别
            if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
            $('#cus_sex_man').attr("checked","checked");
            } else {
            $('#cus_sex_woman').attr("checked","checked");
            }

        })
    </script>
    <li><label style="width:18px;"><b></b></label><label>复印件</label><cite><input name="cus_iscopy"  type="radio" value="1"  />有 &nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_iscopy"  type="radio" value="0"  />无 </cite></li>
    <li><label style="width:18px;"><b>*</b></label><label>性别</label><cite><input name="cus_sex"  id="cus_sex_man" type="radio" value="0"  />男&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_sex" id="cus_sex_woman" type="radio" value="1" />女</cite></li>
    <li><label style="width:18px;"><b></b></label><label>生日</label><input name="cus_birthday" id="cus_birthday" type="text" class="dfinput" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></li>
    <li><label style="width:18px;"><b>*</b></label><label>客户代码</label><input name="cus_number" id="cus_number" type="text" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>EMAIL</label><input name="cus_email" id="cus_email" type="text" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>公司电话</label><input name="cus_tel" id="cus_tel" type="text" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>公司传真</label><input name="cus_fax" id="cus_fax" type="text" class="dfinput" /></li>
    <li><label style="width:18px;"><b></b></label><label>获取三证</label><cite><input name="cus_cert[]"  type="checkbox" value="营业执照" checked="checked" />营业执照　
        <input name="cus_cert[]" value="税务登记证" type="checkbox" checked="checked" />税务登记证　
        <input name="cus_cert[]"  value='组织机构代码证' type="checkbox"  checked="checked" />组织机构代码证　
        </cite>
    </li>
    <li><label style="width:350px;">以上联系人是否已经获取过公司/负责人签署的<委托书>：</label><cite><input name="cus_isget"  type="radio" value='1' checked="checked" />是&nbsp;&nbsp;&nbsp;&nbsp;<input name="cus_isget" type="radio" value="0" />否</cite></li>
    <li><label style="width:18px;"><b>*</b></label>
        <label style="width:86px;">　　业务人员 :</label>
        <label style="width:180px;">
        <div class="vocation">
            <select class="select3" name='cus_business_p' id="cus_business_p">
                <option value='未选择'>请选择</option>
                <option value='华南地区'>华南地区</option>
                <option value='华北地区'>华北地区</option>
            </select>
        </div>
    </label>
        <label style="width:65px;">业务经理 :</label>
        <label style="width:180px;">
            <div class="vocation">
                <select class="select3" name='cus_business_m' id="cus_business_m">
                    <option value='未选择'>请选择</option>
                    <option value='华南地区'>华南地区</option>
                    <option value='华北地区'>华北地区</option>
                </select>
            </div>
        </label>
        <label style="width:65px;">客服部 :</label>
        <label style="width:180px;">
            <div class="vocation">
                <select class="select3" name='cus_service' id="cus_service">
                    <option value='未选择'>请选择</option>
                    <option value='华南地区'>华南地区</option>
                    <option value='华北地区'>华北地区</option>
                </select>
            </div>
        </label>
    </li>
    <li><label style="width:18px;"><b></b></label><label>备注</label><textarea name="cus_remark" cols="" rows="" class="textinput"></textarea></li>
    <li><label style="width:18px;"><b></b></label><label>&nbsp;</label><input name="" type="button" id='btn' class="btn" value="添加"/></li>
    </ul>
    </div>
</form>

</body>
<script type="text/javascript" src="js/WdatePicker.js"></script>
</html>
<script>

$(function(){
    $('#btn').bind('click',function(){
        /*if(!beforeSubmit()){
            return;
        }*/
        $.ajax({
            type:"post",
            data:{'infos':$('#form1').serialize()
            },
            url:"../api/customer.php?action=add",
            success:function(result){
               if(result){
                   window.location.href = "./cuslist.php";
               }else{
                   alert('添加失败');
               }
            },
            error:function(){
                alert("提交错误");
            }
        });
    });

})
</script>
<!--省市联动js-->
<script type="text/javascript">
    var Gid  = document.getElementById ;
    var showArea = function(){
        Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +
        Gid('s_city').value + " - 县/区" +
        Gid('s_county').value + "</h3>"
    }
    Gid('s_county').setAttribute('onchange','showArea()');
</script>
<!--验证表单是否有空项js-->
<script type="text/javascript">
    function beforeSubmit(){
        if($('#cus_name').val()==''){
            alert('用户名不能为空！');
            $('#cus_name').focus();
            return false;
        }
        if($('#cus_linkman').val()==''){
            alert('联系人不能为空！');
            $('#cus_linkman').focus();
            return false;
        }
        if($('#s_province').val()=='省份') {
            alert('省市不能为空！');
            return false;
        }
        if($('#s_city').val()=='地级市') {
            alert('省市不能为空！');
            return false;
        }
        if($('#s_county').val()=='县级市') {
            alert('省市不能为空！');
            return false;
        }
        if($('#cus_birthday').val()==''){
            alert('生日不能为空！');
            return false;
        }
        if($('#cus_address').val()==''){
            alert('地址不能为空！');
            $('#cus_address').focus();
            return false;
        }
        if($('#cus_phone').val()==''){
            alert('手机号不能为空！');
            $('#cus_phone').focus();
            return false;
        }
        if($('#cus_phone').val().length != 11){
            alert('请输入11位手机号');
            $('#cus_phone').focus();
            return false;
        }
        if($('#cus_identity_num').val()==''){
            alert('身份证号码不能为空！');
            $('#cus_identity_num').focus();
            return false;
        }
        if($('#cus_card_number').val()==''){
            alert('卡号不能为空！');
            $('#cus_card_number').focus();
            return false;
        }
        return true;
    }
</script>